/**
 *  X86Compiler.java : IceBird project
 *  22:05:39 
 */
package icebird.compiler.x86.old;

import java.io.FileWriter;
import java.io.IOException;
//import java.util.HashMap;

import icebird.compiler.bytecode.BytecodeVisitor;
import icebird.compiler.x86.old.X86Register.GPR;
//import icebird.metadata.BasicType;
import icebird.metadata.Method;
import icebird.metadata.constpool.ConstClass;
import icebird.metadata.constpool.ConstField;
import icebird.metadata.constpool.ConstIMethod;
import icebird.metadata.constpool.ConstMethod;

/**
 * @author Sergey Shulepoff[Knott]
 */
public final class X86Compiler extends BytecodeVisitor {

	private VirtualStack vs;
	private EmitterContext cntx;
	
	private X86RegisterPool pool;
	
	private X86Assembler asm;
	
	private ItemFactory factory;
	
	//private HashMap<Integer, Item> constLocals = new HashMap<Integer, Item>();
	
	/**
	 * 
	 */
	public X86Compiler() {
		asm = new X86Assembler();
		factory = new ItemFactory();
		
		vs = new VirtualStack();
		pool = new X86RegisterPool();
		
		cntx = new EmitterContext(asm, pool, vs, factory);
		vs.setContext(cntx);
	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#endInstruction()
	 */
	@Override
	public void endInstruction() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#endMethod()
	 */
	@Override
	public void endMethod() {
		vs.push(cntx);
		
		try {
			FileWriter fw = new FileWriter("dist.asm");
			fw.append(asm.toString());
			fw.flush();
		} catch (IOException e) {
			return;
		}
	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#startInstruction(int, byte)
	 */
	@Override
	public void startInstruction(int pc, byte opcode) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#startMethod(icebird.metadata.Method)
	 */
	@Override
	public boolean startMethod(Method method) {
		// TODO Auto-generated method stub
		return true;
	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_aaload()
	 */
	@Override
	public void visit_aaload() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_aastore()
	 */
	@Override
	public void visit_aastore() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_aconst_null()
	 */
	@Override
	public void visit_aconst_null() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_aload(int)
	 */
	@Override
	public void visit_aload(int index) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_anewarray(icebird.metadata.constpool.ConstClass)
	 */
	@Override
	public void visit_anewarray(ConstClass clazz) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_areturn()
	 */
	@Override
	public void visit_areturn() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_arraylength()
	 */
	@Override
	public void visit_arraylength() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_astore(int)
	 */
	@Override
	public void visit_astore(int index) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_athrow()
	 */
	@Override
	public void visit_athrow() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_baload()
	 */
	@Override
	public void visit_baload() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_bastore()
	 */
	@Override
	public void visit_bastore() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_caload()
	 */
	@Override
	public void visit_caload() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_castore()
	 */
	@Override
	public void visit_castore() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_checkcast(icebird.metadata.constpool.ConstClass)
	 */
	@Override
	public void visit_checkcast(ConstClass clazz) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_d2f()
	 */
	@Override
	public void visit_d2f() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_d2i()
	 */
	@Override
	public void visit_d2i() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_d2l()
	 */
	@Override
	public void visit_d2l() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_dadd()
	 */
	@Override
	public void visit_dadd() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_daload()
	 */
	@Override
	public void visit_daload() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_dastore()
	 */
	@Override
	public void visit_dastore() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_dcmpg()
	 */
	@Override
	public void visit_dcmpg() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_dcmpl()
	 */
	@Override
	public void visit_dcmpl() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_dconst(double)
	 */
	@Override
	public void visit_dconst(double value) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_ddiv()
	 */
	@Override
	public void visit_ddiv() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_dload(int)
	 */
	@Override
	public void visit_dload(int index) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_dmul()
	 */
	@Override
	public void visit_dmul() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_dneg()
	 */
	@Override
	public void visit_dneg() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_drem()
	 */
	@Override
	public void visit_drem() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_dreturn()
	 */
	@Override
	public void visit_dreturn() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_dstore(int)
	 */
	@Override
	public void visit_dstore(int index) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_dsub()
	 */
	@Override
	public void visit_dsub() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_dup()
	 */
	@Override
	public void visit_dup() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_dup2()
	 */
	@Override
	public void visit_dup2() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_dup2_x1()
	 */
	@Override
	public void visit_dup2_x1() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_dup2_x2()
	 */
	@Override
	public void visit_dup2_x2() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_dup_x1()
	 */
	@Override
	public void visit_dup_x1() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_dup_x2()
	 */
	@Override
	public void visit_dup_x2() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_f2d()
	 */
	@Override
	public void visit_f2d() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_f2i()
	 */
	@Override
	public void visit_f2i() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_f2l()
	 */
	@Override
	public void visit_f2l() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_fadd()
	 */
	@Override
	public void visit_fadd() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_faload()
	 */
	@Override
	public void visit_faload() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_fastore()
	 */
	@Override
	public void visit_fastore() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_fcmpg()
	 */
	@Override
	public void visit_fcmpg() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_fcmpl()
	 */
	@Override
	public void visit_fcmpl() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_fconst(float)
	 */
	@Override
	public void visit_fconst(float value) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_fdiv()
	 */
	@Override
	public void visit_fdiv() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_fload(int)
	 */
	@Override
	public void visit_fload(int index) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_fmul()
	 */
	@Override
	public void visit_fmul() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_fneg()
	 */
	@Override
	public void visit_fneg() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_frem()
	 */
	@Override
	public void visit_frem() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_freturn()
	 */
	@Override
	public void visit_freturn() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_fstore(int)
	 */
	@Override
	public void visit_fstore(int index) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_fsub()
	 */
	@Override
	public void visit_fsub() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_getfield(icebird.metadata.constpool.ConstField)
	 */
	@Override
	public void visit_getfield(ConstField fieldRef) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_getstatic(icebird.metadata.constpool.ConstField)
	 */
	@Override
	public void visit_getstatic(ConstField fieldRef) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_goto(int)
	 */
	@Override
	public void visit_goto(int address) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_i2b()
	 */
	@Override
	public void visit_i2b() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_i2c()
	 */
	@Override
	public void visit_i2c() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_i2d()
	 */
	@Override
	public void visit_i2d() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_i2f()
	 */
	@Override
	public void visit_i2f() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_i2l()
	 */
	@Override
	public void visit_i2l() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_i2s()
	 */
	@Override
	public void visit_i2s() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_iadd()
	 */
	@Override
	public void visit_iadd() {
		integerOperation(X86Operation.ADD, true);
	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_iaload()
	 */
	@Override
	public void visit_iaload() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_iand()
	 */
	@Override
	public void visit_iand() {
		integerOperation(X86Operation.AND, true);
	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_iastore()
	 */
	@Override
	public void visit_iastore() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_iconst(int)
	 */
	@Override
	public void visit_iconst(int value) {
		vs.push(factory.createIConst(cntx, value));
	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_idiv()
	 */
	@Override
	public void visit_idiv() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_if_acmpeq(int)
	 */
	@Override
	public void visit_if_acmpeq(int address) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_if_acmpne(int)
	 */
	@Override
	public void visit_if_acmpne(int address) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_if_icmpeq(int)
	 */
	@Override
	public void visit_if_icmpeq(int address) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_if_icmpge(int)
	 */
	@Override
	public void visit_if_icmpge(int address) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_if_icmpgt(int)
	 */
	@Override
	public void visit_if_icmpgt(int address) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_if_icmple(int)
	 */
	@Override
	public void visit_if_icmple(int address) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_if_icmplt(int)
	 */
	@Override
	public void visit_if_icmplt(int address) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_if_icmpne(int)
	 */
	@Override
	public void visit_if_icmpne(int address) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_ifeq(int)
	 */
	@Override
	public void visit_ifeq(int address) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_ifge(int)
	 */
	@Override
	public void visit_ifge(int address) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_ifgt(int)
	 */
	@Override
	public void visit_ifgt(int address) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_ifle(int)
	 */
	@Override
	public void visit_ifle(int address) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_iflt(int)
	 */
	@Override
	public void visit_iflt(int address) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_ifne(int)
	 */
	@Override
	public void visit_ifne(int address) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_ifnonnull(int)
	 */
	@Override
	public void visit_ifnonnull(int address) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_ifnull(int)
	 */
	@Override
	public void visit_ifnull(int address) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_iinc(int, int)
	 */
	@Override
	public void visit_iinc(int index, int incValue) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_iload(int)
	 */
	@Override
	public void visit_iload(int index) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_imul()
	 */
	@Override
	public void visit_imul() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_ineg()
	 */
	@Override
	public void visit_ineg() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_instanceof(icebird.metadata.constpool.ConstClass)
	 */
	@Override
	public void visit_instanceof(ConstClass clazz) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_invokeinterface(icebird.metadata.constpool.ConstIMethod, int)
	 */
	@Override
	public void visit_invokeinterface(ConstIMethod methodRef, int count) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_invokespecial(icebird.metadata.constpool.ConstMethod)
	 */
	@Override
	public void visit_invokespecial(ConstMethod methodRef) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_invokestatic(icebird.metadata.constpool.ConstMethod)
	 */
	@Override
	public void visit_invokestatic(ConstMethod methodRef) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_invokevirtual(icebird.metadata.constpool.ConstMethod)
	 */
	@Override
	public void visit_invokevirtual(ConstMethod methodRef) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_ior()
	 */
	@Override
	public void visit_ior() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_irem()
	 */
	@Override
	public void visit_irem() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_ireturn()
	 */
	@Override
	public void visit_ireturn() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_ishl()
	 */
	@Override
	public void visit_ishl() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_ishr()
	 */
	@Override
	public void visit_ishr() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_istore(int)
	 */
	@Override
	public void visit_istore(int index) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_isub()
	 */
	@Override
	public void visit_isub() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_iushr()
	 */
	@Override
	public void visit_iushr() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_ixor()
	 */
	@Override
	public void visit_ixor() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_jsr(int)
	 */
	@Override
	public void visit_jsr(int address) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_l2d()
	 */
	@Override
	public void visit_l2d() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_l2f()
	 */
	@Override
	public void visit_l2f() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_l2i()
	 */
	@Override
	public void visit_l2i() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_ladd()
	 */
	@Override
	public void visit_ladd() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_laload()
	 */
	@Override
	public void visit_laload() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_land()
	 */
	@Override
	public void visit_land() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_lastore()
	 */
	@Override
	public void visit_lastore() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_lcmp()
	 */
	@Override
	public void visit_lcmp() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_lconst(long)
	 */
	@Override
	public void visit_lconst(long value) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_ldc(java.lang.String)
	 */
	@Override
	public void visit_ldc(String value) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_ldc(icebird.metadata.constpool.ConstClass)
	 */
	@Override
	public void visit_ldc(ConstClass value) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_ldiv()
	 */
	@Override
	public void visit_ldiv() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_lload(int)
	 */
	@Override
	public void visit_lload(int index) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_lmul()
	 */
	@Override
	public void visit_lmul() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_lneg()
	 */
	@Override
	public void visit_lneg() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_lookupswitch(int, int[], int[])
	 */
	@Override
	public void visit_lookupswitch(int defValue, int[] matchValues,
			int[] addresses) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_lor()
	 */
	@Override
	public void visit_lor() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_lrem()
	 */
	@Override
	public void visit_lrem() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_lreturn()
	 */
	@Override
	public void visit_lreturn() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_lshl()
	 */
	@Override
	public void visit_lshl() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_lshr()
	 */
	@Override
	public void visit_lshr() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_lstore(int)
	 */
	@Override
	public void visit_lstore(int index) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_lsub()
	 */
	@Override
	public void visit_lsub() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_lushr()
	 */
	@Override
	public void visit_lushr() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_lxor()
	 */
	@Override
	public void visit_lxor() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_monitorenter()
	 */
	@Override
	public void visit_monitorenter() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_monitorexit()
	 */
	@Override
	public void visit_monitorexit() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_multianewarray(icebird.metadata.constpool.ConstClass, int)
	 */
	@Override
	public void visit_multianewarray(ConstClass clazz, int dimensions) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_new(icebird.metadata.constpool.ConstClass)
	 */
	@Override
	public void visit_new(ConstClass clazz) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_newarray(int)
	 */
	@Override
	public void visit_newarray(int type) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_nop()
	 */
	@Override
	public void visit_nop() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_pop()
	 */
	@Override
	public void visit_pop() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_pop2()
	 */
	@Override
	public void visit_pop2() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_putfield(icebird.metadata.constpool.ConstField)
	 */
	@Override
	public void visit_putfield(ConstField fieldRef) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_putstatic(icebird.metadata.constpool.ConstField)
	 */
	@Override
	public void visit_putstatic(ConstField fieldRef) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_ret(int)
	 */
	@Override
	public void visit_ret(int index) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_return()
	 */
	@Override
	public void visit_return() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_saload()
	 */
	@Override
	public void visit_saload() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_sastore()
	 */
	@Override
	public void visit_sastore() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_swap()
	 */
	@Override
	public void visit_swap() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see icebird.compiler.bytecode.BytecodeVisitor#visit_tableswitch(int, int, int, int[])
	 */
	@Override
	public void visit_tableswitch(int defValue, int lowValue, int highValue,
			int[] addresses) {
		// TODO Auto-generated method stub

	}
	
	private final boolean isConstants(Item v0, Item v1) {
		return v0.isConstant() && v1.isConstant();
	}
	
	private final boolean prepareForOp(Item dst, Item src, boolean c) {
		if (c) {
			if (dst.getKind() < src.getKind()) {
				src.load(cntx);
				dst.loadIf(cntx, Item.FPUSTACK | Item.STACK);
				return true;
			}
		}
		
		src.loadIf(cntx, Item.FPUSTACK | Item.STACK);
		dst.load(cntx);
		return false;
	}
	
	//

	/**
	 * Emit integer operation.
	 * @return void
	 */
	private final void integerOperation(int op, boolean c) {
		IntegerItem v0 = vs.popInteger();
		IntegerItem v1 = vs.popInteger();
		
		if (isConstants(v0, v1)) {
			int v = 0;
			
			switch (op) {
			case X86Operation.ADD:
				v = v0.getValue() + v1.getValue();
				break;
				
			case X86Operation.SUB:
				v = v0.getValue() - v1.getValue();
				break;
				
			case X86Operation.XOR:
				v = v0.getValue() ^ v1.getValue();
				break;
				
			case X86Operation.AND:
				v = v0.getValue() & v1.getValue();
				break;
				
			case X86Operation.OR:
				v = v0.getValue() | v1.getValue();
				break;
				
			default:
				throw new RuntimeException("Wrong operation");
			}
			
			v0.release(cntx);
			v1.release(cntx);
			
			vs.push(factory.createIConst(cntx, v));
		} else {
			if (prepareForOp(v0, v1, c)) {
				// Swap
                IntegerItem tmp = v1;
                v1 = v0;
                v0 = tmp;
			}
			
			GPR r0 = v0.getRegister();
			switch (v1.getKind()) {
			case Item.GPR:
				asm.artOp(op, r0, v1.getRegister());
				break;
				
			case Item.LOCAL:
				asm.artOp(op, r0, X86Register.EBP, v1.bpOffset());
				break;
				
			case Item.CONSTANT:
				asm.artOp(op, r0, v1.getValue());
			}
			
			v1.release(cntx);
			vs.push(v1);
		}
	}
}
